$(".editPassword").children(".content").children("div").children("input").blur(function () {
    var test = /^[0-9a-zA-Z_.\-=]{8,15}$/;
    if (!test.test($(this).val())) {
        $(this).parent().children(".errorMsg").text("长度限度8~15,特殊符号限定_.-=");
        // $("#dormHighSearchBtn").attr("disable","disable");
    } else {
        $(this).parent().children(".errorMsg").empty();
    }

    setTimeout(function () {
        var flag = true;
        $(".editPassword").children(".content").children(".SHinput").each(function () {
            flag = flag && $(this).hasClass("input_success");
            // console.log(flag);
        });
        if (flag == false) {
            // console.log( $("#changePasswordInput"));
            $("#changePasswordInput").attr("disabled", "disabled");
            $("#changePasswordInput").addClass("button_cannot");
        } else {
            // console.log($("#changePasswordInput"));
            $("#changePasswordInput").removeAttr("disabled");
            $("#changePasswordInput").removeClass("button_cannot");
        }
    }, 10);
});

$("#changePasswordInput").click(function () {
    var token = localStorage['token'];
    var oriPassword = $("#oriPassword").val();
    var newPassword = $("#newPassword").val();
    var newPasswordTwi = $("#newPasswordTwi").val();
    if (newPassword != newPasswordTwi) {

        message("两次输入新密码不一致", "请保证两次密码输入一致", "error", 1000);
    } else if (newPassword == oriPassword) {
        message("新旧密码一致", "请重新修改新密码", "error", 1000);

    } else {
        $.ajax({
                url: "/user/password/update",
                type: "POST",
                data: {
                    "token": token,
                    "oriPassword": oriPassword,
                    "newPassword": newPassword
                },
                success: function (data) {
                    if (data.code == 500) {
                        message(data.msg, "请修改后重新尝试", "error", 1500);
                    } else if (data.code = 200) {
                        message(data.msg, "密码修改成功,请重新登录!", "success", 2000);
                        setTimeout(function () {
                            load(document.body, 10000);
                            localStorage.clear();
                            // crossMessaeg("注销成功","success");
                            setTimeout(function () {
                                window.location.href = "../../..";
                            }, 2000);
                        }, 1000);

                    }
                }
            }
        )
    }
});

